package com.binary.coder.gift.core.domain.invitation.impI;

import com.binary.coder.gift.core.common.bean.PageBean;
import com.binary.coder.gift.core.domain.invitation.model.aggregate.HandleInvitationRecordAggregate;
import com.binary.coder.gift.core.domain.invitation.model.aggregate.InvitationCardAggregate;
import com.binary.coder.gift.core.domain.invitation.model.entity.InvitationRecordEntity;
import com.binary.coder.gift.core.domain.invitation.repository.InvitationRepository;
import com.binary.coder.gift.core.domain.invitation.InvitationService;
import com.binary.coder.gift.core.interfaces.Invitation.dto.req.PageQueryInvitationCardReq;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @author atao
 * @version 1.0.0
 * @ClassName InviatationService.java
 * @Description 请帖服务
 * @createTime 2024年06月21日 16:51:00
 */
@Service
public class InvitationServiceImpI implements InvitationService {

    @Resource
    private InvitationRepository invitationRepository;

    @Override
    public long saveInvitation(InvitationCardAggregate invitationCardAggregate) {
        return invitationRepository.saveOrUpdateInvitation(invitationCardAggregate);
    }

    @Override
    public boolean checkPermission(long userId, long invitationCardId) {
        return false;
    }

    @Override
    public boolean deleteInvitationCardById(long invitationCardId) {
        invitationRepository.deleteInvitationCardById(invitationCardId);
        return true;
    }

    @Override
    public PageBean<InvitationCardAggregate> pageQueryInvitationCard(PageQueryInvitationCardReq req) {
        return invitationRepository.pageQueryInvitationCard(req);
    }

    @Override
    public void saveInvitationRecord(InvitationRecordEntity entity) {
        invitationRepository.saveInvitationRecord(entity);
    }

    @Override
    public InvitationCardAggregate queryInvitationCard(Long invitationCardId) {
        return invitationRepository.queryInvitationCard(invitationCardId);
    }

    @Override
    public HandleInvitationRecordAggregate queryInvitationRecord(Long userId, Long invitationCardId) {
        return invitationRepository.queryInvitationRecord(userId,invitationCardId);
    }

    @Override
    public PageBean<HandleInvitationRecordAggregate> pageQueryInvitationRecord(long pageIndex, long pageSize, Long invitationId) {
        return invitationRepository.pageQueryInvitationRecord(pageIndex,pageIndex,invitationId);
    }
}
